
function oppower(op) {
    

  var app = getApp();

  if (app.globalData.member && (app.globalData.member.member_id != "0")) {
   
    return new Promise(resolve => {
      resolve({ status: 1,obj:app.globalData.member})
    })
  }
  else {    
    if (!app.globalData.configdata) {
      return new Promise(resolve => {
      resolve({ status: -1, message: "未登录,正在加载配制信息" })
      })
    }
    var powstatus = app.globalData.configdata.authorization.status  //全站要登录，2购买需要登录，3无需登录
    if (powstatus == "1") {
      return new Promise(resolve => {
        logininfo(true).then(res => {
          resolve(res)
        })
      })
    }
    
    switch (op) {
      case "login": { 
          return new Promise(resolve => {
            logininfo().then(res => {
              resolve(res)
            })
          })        
      }
      case "pro": {
        if (powstatus == "2") {
          return new Promise(resolve => {
            logininfo().then(res => {
              resolve(res)
            })
          })
        }
      }
    }
    return new Promise(resolve => {
      resolve({ status: -1, message: "无触发条件" })
    })
  }
}

function clublogin(){


}
function logininfo() {
  var app = getApp();
  var pages = getCurrentPages()
  var currentPage = pages[pages.length - 1]
  var actusereg = currentPage.selectComponent("#usereg")
  if (!app.globalData.member) {
    return new Promise(resolve => {
      if (app.globalData.islogin) {
        actusereg.show(function (member) {
          resolve({ "status": 1 ,obj:member})
        })
        return;
      }
      else {
        app.xc_sys_config.getuserinfo().then(res => {
          if (res.status == 1) {
            var memeber=app.globalData.member
            if (memeber.member_id == "0") {
              var pages = getCurrentPages()
              actusereg.show(function (member) {
                resolve({ "status": 1,obj:member })
              })
            }
            else {
              resolve({ "status": 1,obj:memeber })
            }
          }
          else {
            resolve({ "status": -1 })
          }
        })
      }

    })
  }
  else {
    return new Promise(resolve => {
      if (app.globalData.member.member_id == "0") {

        var actusereg = currentPage.selectComponent("#usereg")
        actusereg.show(function (member) {
          resolve({ "status": 1,obj:member})
        })
      }
      else {
        resolve({ "status": 1,obj:app.globalData.membe })
      }
    })
  }
}

module.exports = {
  oppower: oppower
}